var UranusWei = angular.module("UranusWei");
// 活期列表
UranusWei.controller("currentlist", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'uranusPlus', 'appconfig', '$timeout', '$interval', '$stateParams', 'CacheFactory', '$location', function ($scope, $rootScope, uranusiscroll, commonFactory, uranusPlus, appconfig, $timeout, $interval, $stateParams, CacheFactory, $location) {
    $rootScope.Template = {
        title: '活期',
        state: 'mainday',
        showbackicon: false,
        showheader: true,
        backlink:'/main/home'
    }
    CacheFactory.setStorage('day_producturl', $location.path());
    CacheFactory.setStorage('time_comebackUrl', '/main/day', { isExpires: true, expiresTime: CacheFactory.hour * 1 })//开户回调地址
    $scope.drawNum = 0;//定义动画
    var dthis = new uranusiscroll();
    var pathName = location.pathname;
    if (window.location.pathname == "/day/currentdetail") {
        $rootScope.Template.state='currentdetail'
        uranusiscroll = dthis.init(false, false);
    } else {
        uranusiscroll = dthis.init(false, false, true);
    }
    uranusiscroll.pullDownAction = function () {
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    $scope.user = null;//用户信息
    $scope.submit = {};
    function draw(percent, sR) {
        if (!document.querySelector('#canvas')) {
            return false
        }
        if (percent < 0 || percent > 100) {
            return;
        }
        if (sR < Math.PI / 2 || sR >= 3 / 2 * Math.PI) {
            return;
        }
        var canva = document.querySelector('#canvas'),
            cxt = canva.getContext('2d'),
            cWidth = canva.width,
            cHeight = canva.height,
            baseColor = '#eaedff',
            coverColor = '#3552ff',
            textcolor = '#000'
        PI = Math.PI,
            sR = sR || 1 / 2 * PI; // 默认圆弧的起始点弧度为π/2
        var finalRadian = sR + ((PI + (PI - sR)) * percent / 100); // 终点弧度
        var step = (PI + (PI - sR) * 2) / 100; // 一个1%对应的弧度大小
        var text = 0;

        window.requestAnimationFrame(paint);
        function paint() {
            cxt.clearRect(0, 0, cWidth, cHeight);
            var endRadian = sR + text * step;
            var lGrd = cxt.createLinearGradient(endRadian, endRadian, cHeight, cHeight);
            lGrd.addColorStop(0, '#3552ff');
            lGrd.addColorStop(0.6, '#3552ff');
            lGrd.addColorStop(1, '#20e4ff');
            // 画灰色圆弧
            drawCanvasarc(cWidth / 2, cHeight / 1.04, cHeight / 1.3, sR, sR + (PI + (PI - sR) * 2), baseColor, 20);
            // 画蓝色圆弧
            drawCanvasarc(cWidth / 2, cHeight / 1.04, cHeight / 1.3, sR, endRadian, lGrd, 20);
            text++;
            if (endRadian.toFixed(2) < finalRadian.toFixed(2)) {
                window.requestAnimationFrame(paint);
            }
        }
        function drawCanvasarc(x, y, r, sRadian, eRadian, color, lineWidth) {
            cxt.beginPath();
            cxt.lineCap = "round";
            cxt.strokeStyle = color;
            cxt.lineWidth = lineWidth;
            cxt.arc(x, y, r, sRadian, eRadian, false);
            cxt.stroke();
        }
    }
    draw($scope.drawNum.toFixed(0), (Math.PI))
    /* 检测输入的金额是否符合购买要求 */
    $scope.GetProfit = function (keypress) {
        checkPrice(true);
    };
    var view = document.querySelector(".dthview")
    window.onresize = function () {
        view.style.position = "relative";    //resize时设置定位为相对定位
    }
    view.style.position = "fixed";
    var nofocus = document.querySelector('.nofocus')
    nofocus.addEventListener('touchstart', function () {
        commonFactory.inputBlur();
    }, false);
    var checkPrice = function (keypress) {
        var submit = $scope.submit;
        submit.shopprice = parseFloat(submit.shopprice);
        if (!submit.shopprice || isNaN(parseFloat(submit.shopprice)) || parseFloat(submit.shopprice) == 0) {
            if (!keypress) {
                commonFactory.messageshow({ content: "<div class='bg_tan'>请输入购买金额</div>" });
            }
            return false;
        } else if ($scope.GetFlexibleUserCanBuyPrice > 0 && submit.shopprice < $scope.GetCanBuyFlexible.MinBuyPrice) {//当可够金额大于0 && 购买金额大于最小购买金额
            if (!keypress) {
                commonFactory.messageshow({ content: "<div class='bg_tan'>该产品购买金额最少为" + $scope.GetCanBuyFlexible.MinBuyPrice + "元</div>" });
                submit.shopprice = $scope.GetCanBuyFlexible.MinBuyPrice
            }
            return false;
        }
        /* 单笔最大购买金额 */
        if ($scope.SurplusCanBuy >= 0 && submit.shopprice > $scope.SurplusCanBuy) {
            if (!keypress) {
                commonFactory.messageshow({ content: "<div class='bg_tan'>当前最大可购金额为" + $scope.SurplusCanBuy + "元</div>" });
            }
            return false;
        }
        return true;
    };
    var initdata = function () {
        function timeShow() {
            $rootScope.djsshow = true;//显示定时器开关
            function setproducttime() {
                $scope.djstimes = $scope.serviceTime.getTime();//当前时间
                var ndate = $scope.serviceTime;
                var year = ndate.getFullYear();
                var month = ndate.getMonth() + 1;
                var date = ndate.getDate();
                var off = true
                if (ndate.getHours() == '00' && off) {//
                    var pretime = new Date($scope.serviceTime.getTime() - 86400000)
                    date = pretime.getDate();
                    month = pretime.getMonth() + 1;
                    off = false;
                }
                var hours = $scope.gethours;//配置时间小时
                var min = $scope.getMinutes;//分钟
                var seconds = $scope.getSecond;//秒
                var newDate = year + '-' + month + '-' + date + ' ' + hours + ':' + min + ':' + seconds;
                // console.log(newDate)
                $scope.newDate = new Date(newDate.replace(/-/g, '/')).getTime();//设定时间
                var enddjs = $scope.thistime * 60000 + 1000;//时间段
                var cdate = $scope.newDate + enddjs//结束时间
                // console.log(new Date(cdate))
                function djsminutes() {
                    $scope.djsshow = false;
                    djsmin = parseInt(enddjs / 60000);
                    djssec = parseInt(enddjs % 60000 / 1000);
                    if (djssec && djsmin) {
                        $scope.begindjs = djsmin + '分' + djssec + '秒';
                    } else if (!djssec && djsmin) {
                        $scope.begindjs = djsmin + '分';
                    } else if (!djsmin) {
                        $scope.begindjs = djssec + '秒';
                    }
                }
                if ($scope.djstimes >= $scope.newDate && $scope.djstimes <= cdate) {
                    thisdjs = $scope.djstimes - $scope.newDate;
                    enddjs = enddjs - thisdjs;
                    djsminutes()
                    var clear = $interval(function () {
                        if ($scope.djstimes >= cdate) {
                            $scope.djsshow = true;
                            $interval.cancel(clear)
                        } else {
                            enddjs = enddjs - 1000;
                            djsminutes();
                        }
                    }, 1000)
                }
                $timeout(function () {
                    $scope.serviceTime = new Date($scope.serviceTime.getTime() + 1000);
                    uranusiscroll.refresh();
                }, 300);
            }
            setproducttime();
            $scope.$on('$destroy', function () {
                $interval.cancel(intervalL)
            })
            var intervalL = $interval(function () {
                setproducttime()
            }, 1000)
        }

        $scope.canvasHeight = window.innerWidth * 0.47;
        $scope.SurplusCanBuy = 0;
        $scope.user = CacheFactory.getUser();

        //活期倒计时
        var reqstime, reqetime, reqcha;
        // 获取请求开始的时间
        reqstime = new Date().getTime();
        commonFactory.ajax("/api/UserFlexibleProduct/GetServiceTime", {}, function (result) {
            // 获取请求结束的时间
            reqetime = new Date().getTime();
            // 计算请求所用时间
            reqcha = reqetime - reqstime;
            // 后台返回的时间加上请求所用时间就是当前时间
            $scope.serviceTime = new Date(new Date(parseInt(result.data.serviceTime)).getTime() + reqcha);//
            //时间段
            $scope.thistime = result.data.minute;
            //开始时间
            $scope.gethours = result.data.startTime.substring(0, 2);
            $scope.getMinutes = parseInt(result.data.startTime.substring(3, 5));
            $scope.getSecond = parseInt(result.data.startTime.substring(6, 8));
            timeShow();
        }, function () { }, 'get')

        // 读取可买活期标缓存
        var time_GetCanBuyFlexible = CacheFactory.getStorage("time_GetCanBuyFlexible")
        if (time_GetCanBuyFlexible) {
            $scope.GetCanBuyFlexible = time_GetCanBuyFlexible.product
            $scope.GetFlexibleUserCanBuyPrice = time_GetCanBuyFlexible.price
            $scope.SurplusCanBuy = time_GetCanBuyFlexible.price
            if (window.location.pathname == "/day/currentdetail") {
                $timeout(function () {
                    uranusiscroll.refresh();
                }, appconfig.pulldowntime);
            }
            var productname = $scope.GetCanBuyFlexible.productName;
            $rootScope.Template.title = productname;
        }
        $scope.closelayout = function () {//
            commonFactory.messageclose();
        }
        commonFactory.ajax("/api/UserFlexibleProduct/GetProductById", {}, function (result) {
            if (result.code == 1 && result.data && result.data != null) {
                var data = result.data;
                $scope.GetCanBuyFlexible = data.product;
                $scope.SurplusCanBuy = data.price
                CacheFactory.setStorage("time_GetCanBuyFlexible", data, { isExpires: true, expiresTime: CacheFactory.day * 1 });

                if (window.location.pathname == "/day/currentdetail") {
                    $timeout(function () {
                        uranusiscroll.refresh();
                    }, appconfig.pulldowntime);
                }
                $scope.drawNum = ($scope.GetCanBuyFlexible.loanPrice - $scope.GetCanBuyFlexible.surplusCanBuy) / $scope.GetCanBuyFlexible.loanPrice * 100;
                draw($scope.drawNum.toFixed(0), (Math.PI))

                $scope.currentBuy = function () {
                    commonFactory.inputBlur();
                    if (!$scope.user) {//检测登录---弹出
                        commonFactory.gologin();
                        return;
                    }
                    commonFactory.ajax("/api/user/getuserinfo", {}, function (result) {
                        if (result.code == 1) {
                            if (result.data.userId <= 0) {//检测登陆
                                commonFactory.gologin();
                                return;
                            }
                            var userinfo = result.data;
                            if (userinfo.usrCustId == null || !userinfo.usrCustId) {
                                // commonFactory.go("/mine/realname");
                                commonFactory.ajax("/api/bank/gettime", {}, function (result) {
                                    if (result.code == 1) {
                                        commonFactory.messageclose();
                                        var severseTime = new Date(new Date(result.data.replace(/-/g, '/')).getTime()); //服务器时间
                                        var nhours = severseTime.getHours();
                                        var nminutus = severseTime.getMinutes();
                                        if (nhours >= 1 && nhours <= 5) {
                                            var html = '<div id="js_singlePrice">';
                                            html += '       <section class="withtan_box">';
                                            html += '           <p class="clearfix witht_b_tit">';
                                            html += '               <span class="text_center">&nbsp;提示</span>';
                                            html += '               <span class="pull-right with_b_t_icon" ng-click="closelayout()"></span>';
                                            html += '           </p>';
                                            html += '           <div class="withtan_content">';
                                            html += '               <div class="clearfix with_c_div" style="padding-bottom:1.0667rem">';
                                            html += '                   为了保障用户资金安全，平台1:00--5:00为银行对账时段，暂停汇付天下账户开通，请您稍后操作。感谢您的理解与支持。';
                                            html += '               </div>';
                                            html += '               <div class="withtan_content_bth with_c_p_but_color" ng-click="closelayout()">';
                                            html += '                   我知道了';
                                            html += '               </div>';
                                            html += '           </div>';
                                            html += '       </section>';
                                            html += '   </div>';
                                            commonFactory.messageview(html, { width: 1, height: 1 }, $scope);
                                        } else {
                                            commonFactory.go('/mine/realname')
                                        }
                                    }
                                }, function () { }, 'post')
                                return;
                            } else {
                                if (checkPrice()) {//活期购买验证
                                    commonFactory.messageloading();
                                    commonFactory.ajax("/api/UserFlexibleProduct/CanInvestProduct", { Price: $scope.submit.shopprice, ProductId: $scope.GetCanBuyFlexible.id }, function (result) {//确定投标
                                        commonFactory.messageclose();
                                        CacheFactory.setStorage("time_shopprice", $scope.submit.shopprice);
                                        if (result.code == 1) {
                                            var gid = $scope.GetCanBuyFlexible.id;
                                            commonFactory.go("/day/currentorderconfirmpayment/" + gid);//跳转订单购买页面
                                        } else if (result.code == 8) {
                                            commonFactory.gologin();
                                        } else if (result.data == '活期非操作时间') {
                                            commonFactory.messageclose();
                                            commonFactory.messageshow({ content: "<div class='bg_tan'>预计00:10开售</div>" });
                                        } else {
                                            if (result.data) {
                                                commonFactory.messageshow({ content: "<div class='bg_tan'>" + result.data + "</div>" });
                                            } else {
                                                commonFactory.messageshow({ content: "<div class='bg_tan'>购买产品失败，请稍后再试</div>" });
                                            }
                                        }
                                    }, null, "post");
                                }
                            }
                        } else if (result.code == 8) {
                            commonFactory.gologin();
                        } else {
                            commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
                        }
                    }, function () {
                        commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
                    }, "post");

                }
            } else {
                draw(100, (Math.PI));
            }
        }, null, "get");
    }
    initdata();
}]);
// 活期订单确认
UranusWei.controller("currentorderconfirmpayment", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'appconfig', '$timeout', '$interval', '$stateParams', 'CacheFactory', '$location', function ($scope, $rootScope, uranusiscroll, commonFactory, appconfig, $timeout, $interval, $stateParams, CacheFactory, $location) {
    $rootScope.Template = {
        title: '活期订单确认',
        state: 'currentorderconfirmpayment',
        showbackicon: true,
        showheader: true,
        backlink: ''
    }
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(true, false, false, true);
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    $scope.orderinfoplus = {
        agreeprotocol: true/* 用户协议 */
    };
    var initdata = function () {
        commonFactory.messageloading({ process: true });
        var loadingArr = [], loadingCount = 2;
        commonFactory.initComplate(loadingArr, loadingCount, function () {
            commonFactory.messageclose();
        });
        var id = $stateParams.id;
        CacheFactory.setStorage('time_comebackUrl', '/day/currentorderconfirmpayment/' + id, { isExpires: true, expiresTime: CacheFactory.hour * 1 })//快捷充值回调地址
        if (id) {
            // 计算购买活期利息
            function CalcInterest() {
                commonFactory.ajax("/api/UserFlexibleProduct/CalcInterest", { ProductId: id, price: $scope.getprice }, function (result) {//计算收益
                    if (result.code == 1) {
                        $scope.getMyPrice = result.data;
                        CacheFactory.setStorage("time_getMyPrice", result.data)
                    } else if (result.code == 8) {
                        commonFactory.gologin();
                    } else {
                        commonFactory.messageshow({ content: "<div class='bg_tan'>" + result.data + "</div>" });
                    }
                }, function () { }, "post");
            }
            $scope.getprice = CacheFactory.getStorage("time_shopprice")
            // 解决android（第一次读取不到缓存）读取缓存慢的问题
            if (!$scope.getprice) {
                var getcount = 0;
                var priceInterval = $interval(function () {
                    $scope.getprice = CacheFactory.getStorage("time_shopprice");// 购买金额
                    getcount++;
                    if ($scope.getprice || getcount > 10) {
                        $interval.cancel(priceInterval)
                        CalcInterest()
                    }
                }, 50)

            } else {
                CalcInterest()
            }
            var resuserinfo = CacheFactory.getUser();
            if (resuserinfo) {
                $scope.resuserinfo = resuserinfo;
            }
            commonFactory.ajax("/api/UserFlexibleProduct/GetProductById", {}, function (result) {//订单页信息
                loadingArr.push("GetProductById");
                if (result.code == 1 && result.data && result.data != null) {
                    $scope.orderinfo = result.data.product;
                } else if (result.code == 8) {
                    commonFactory.gologin();
                } else {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>" + result.data + "</div>" });
                }
            }, function () { }, "get");
            // 获取银行卡限额
            function getbankinfo() {
                var banklimitList = CacheFactory.getStorage("banklimitList");
                if (banklimitList && banklimitList.length > 0) {
                    banklimitList.forEach(function (obj) {
                        if (obj.bankCode && $scope.getuserinfo.bankCode) {
                            if (obj.bankCode.toLowerCase() == $scope.getuserinfo.bankCode.toLowerCase()) {
                                $scope.bankInfo = obj;
                                $scope.bankInfo.bankIcon = $rootScope.imgbaseurl + $scope.bankInfo.bankCode + '.png'
                            }
                        }
                    })
                }
                commonFactory.ajax("/api/bank/GetBankLimitList", {}, function (result) {//限额列表
                    if (result.code == 1) {
                        CacheFactory.setStorage("banklimitList", result.data);
                        if (result.data.length > 0) {
                            result.data.forEach(function (obj) {
                                if (obj.bankCode && $scope.getuserinfo.bankCode) {
                                    if (obj.bankCode.toLowerCase() == $scope.getuserinfo.bankCode.toLowerCase()) {
                                        $scope.bankInfo = obj;
                                        $scope.bankInfo.bankIcon = $rootScope.imgbaseurl + $scope.bankInfo.bankCode + '.png'
                                    }
                                }
                            })
                        }
                    }
                }, function () {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>获取银行限额表失败</div>" });
                }, "post");
            }
            //获取用户绑定的银行卡
            var cache_bankinfo = CacheFactory.getStorage("user_bankinfo");
            if (cache_bankinfo) {
                getbankinfo()
                loadingArr.push("GetUserBankInfo");
            }
            commonFactory.ajax("/api/user/getuserinfo", {}, function (result) {//银行卡信息
                if (!cache_bankinfo) {
                    loadingArr.push("GetUserBankInfo");
                }
                if (result.code == 1) {
                    if (result.data.userId <= 0) {
                        commonFactory.gologin();
                        return;
                    }
                    var data = result.data;
                    $scope.getuserinfo = data
                    if (data.bankCard) {
                        getbankinfo()
                    }
                    $timeout(function () {
                        uranusiscroll.refresh();
                    }, 300);
                } else if (result.code == 8) {
                    commonFactory.gologin();
                } else {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>获取银行卡信息失败</div>" });
                }
            }, function () {
                if (!cache_bankinfo) {
                    loadingArr.push("GetUserBankInfo");
                }
                $timeout(function () {
                    uranusiscroll.refresh();
                }, 300);
                commonFactory.messageshow({ content: "<div class='bg_tan'>获取银行卡信息失败</div>" });
            }, "post");
            commonFactory.ajax("/api/price/myprice", {}, function (result) {
                if (result.code == 1) {
                    $scope.userinfo = result.data;
                    $scope.userinfo.usablePrice = result.data.usableCash;
                    if ($scope.userinfo.usableAmount < $scope.getprice) {//余额不足 弹出框去充值绑定值
                        $scope.reduce = ($scope.getprice * 100 - $scope.userinfo.usableAmount * 100) / 100;
                        CacheFactory.setStorage("chargeprice", $scope.reduce)//设置充值成功页面显示金额缓存
                    }
                }
            }, function () {
                commonFactory.messageshow({ content: "<div class='bg_tan'></div>" });
            }, "post");
        } else {
            commonFactory.go("back");
        }
    }
    /*关闭弹层*/
    $scope.closelayout = function () {
        commonFactory.messageclose();
    }
    /*确认支付*/
    // 充值提交信息
    $scope.rechargeData = {
        RetUrl: "",
        PageType: '2',
        GateBusiId: "QP",
        TransAmt: "",
        OpenBankId: ''
    }
    $scope.gopay = function () {
        if (!$scope.orderinfoplus.agreeprotocol) {
            commonFactory.messageshow("<div class='bg_tan'>请先同意相关协议、风险提示函及免责声明</div>");
            return;
        }
        if ($scope.getuserinfo.bankCode && $scope.bankInfo.singlePrice < $scope.reduce) {//充值金额大于银行限额弹框
            var js_fastpay = document.querySelector("#js_singlePrice");
            if (js_fastpay) {
                var html = js_fastpay.innerHTML;
                commonFactory.messageview(html, { height: 1, width: 1, shadeClose: true }, $scope);
            }
            return;
        } else if ($scope.userinfo.usableAmount < $scope.getprice) {//快捷充值弹框
            var js_fastpay = document.querySelector("#js_recharge");
            if (js_fastpay) {
                var html = js_fastpay.innerHTML;
                commonFactory.messageview(html, { height: 1, width: 1, shadeClose: true }, $scope);
            }
            return;
        } else {
            $scope.enterpay(1)
        }
    }
    $scope.enterpay = function (type) {
        if (type == 1) {
            commonFactory.messageloading({ index: 2000, time: 1000 * 60 * 10 });
            //直接支付
            commonFactory.ajax("/api/UserFlexibleProduct/InvestFleibleProduct", { ProductId: $stateParams.id, Price: $scope.getprice, RetUrl: appconfig.baseurladd + '/other/waitting?type=currentpay', PageType: '2' }, function (result) {
                if (result.code == 1) {
                    $scope.FleibleProduct = result.data
                    commonFactory.ajax("/api/UserProduct/GetOrderId", { orderCode: result.data.ordId }, function (result) {
                        if (result.data) {
                            CacheFactory.setStorage("time_queryresult", result.data);//订单编号
                            var formObject = document.querySelector('#rechargeform')
                            formObject.action = appconfig.hfurl;
                            $scope.ajaxdata = $scope.FleibleProduct;
                            $timeout(function () {
                                formObject.submit();
                            }, 50)
                        }
                    }, function () {

                    }, "get");

                } else if (result.code == 8) {
                    commonFactory.goLogin();
                } else if (result.data == '活期非操作时间') {
                    commonFactory.messageclose();
                    commonFactory.messageshow({ content: "<div class='bg_tan'>预计00:10开售</div>" });
                } else {
                    commonFactory.messageclose();
                    if (result.data) {
                        commonFactory.messageshow({ content: "<div class='bg_tan'>" + result.data + "</div>" });
                    } else {
                        commonFactory.messageshow({ content: "<div class='bg_tan'>支付失败，请稍后再试！</div>" });
                    }
                }
            }, function () {
                commonFactory.messageclose();
                commonFactory.messageshow({ content: "<div class='bg_tan'>支付失败，请稍后再试！</div>" });
            }, "post");
        } else if (type == 2) { //快捷支付
            commonFactory.messageclose();
            // 充值确认
            $scope.rechargeData.RetUrl = appconfig.baseurladd + '/other/waitting?type=rechargeon';
            $scope.rechargeData.TransAmt = ($scope.getprice - $scope.userinfo.usableAmount).toFixed(2);
            commonFactory.ajax("/api/Account/Recharge", $scope.rechargeData, function (result) {
                if(result.code==2){
                    var js_fastpay = document.querySelector("#js_banrecharge");
                    if (js_fastpay) {
                        var html = js_fastpay.innerHTML;
                        commonFactory.messageview(html, { height: 1, width: 1, shadeClose: true }, $scope);
                    }
                }else{
                    CacheFactory.setStorage("time_queryresult", result.merPriv);
                    var formObject = document.querySelector('#rechargeform')
                    formObject.action = appconfig.hfurl;
                    $scope.ajaxdata = result;
                    $timeout(function () {
                        formObject.submit();
                    }, 50)
                }
            }, function () {
                commonFactory.messageclose();
                commonFactory.messageshow({ content: "<div class='bg_tan'>支付失败，请稍后再试！</div>" });
            }, "post");
        }
    }

    initdata();
}]);
// 天天赚账户
UranusWei.controller("daydetailed", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'uranusPlus', 'appconfig', '$timeout', '$interval', '$stateParams', 'CacheFactory', '$location', function ($scope, $rootScope, uranusiscroll, commonFactory, uranusPlus, appconfig, $timeout, $interval, $stateParams, CacheFactory, $location) {
    $rootScope.Template = {
        title: '天天赚账户',
        state: 'daydetailed',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,
        opacity: 0,
        backlink: '/main/mine'
    }
    CacheFactory.setStorage('time_comebackUrl', '/mine/daydetailed', { isExpires: true, expiresTime: CacheFactory.hour * 1 })//设置开户回调地址
    // commonFactory.setBackLink("/main/mine");
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, false);
    var pathName = location.pathname;
    uranusiscroll.scrollMove = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }
    uranusiscroll.scrollEnd = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    uranusiscroll.pullUpAction = function () {
        getdaylist(true);
    }
    function timeShow() {
        $scope.djsshowprice = true;
        function setproducttime() {
            $scope.djstimes = $scope.serviceTime.getTime();//当前时间
            var ndate = $scope.serviceTime;
            var year = ndate.getFullYear();
            var month = ndate.getMonth() + 1;
            var date = ndate.getDate();
            var off = true
            if (ndate.getHours() == '00' && off) {//
                var pretime = new Date($scope.serviceTime.getTime() - 86400000)
                date = pretime.getDate();
                month = pretime.getMonth() + 1;
                off = false;
            }
            var hours = $scope.gethours;//配置时间小时
            var min = $scope.getMinutes;//分钟
            var seconds = $scope.getSecond;//秒
            var newDate = year + '-' + month + '-' + date + ' ' + hours + ':' + min + ':' + seconds;
            // console.log(newDate)
            $scope.newDate = new Date(newDate.replace(/-/g, '/')).getTime();//设定时间
            var enddjs = $scope.thistime * 60000 + 1000;//时间段
            var cdate = $scope.newDate + enddjs//结束时间
            // console.log(new Date(cdate))
            function djsminutes() {
                $scope.djsshowprice = false;
                djsmin = parseInt(enddjs / 60000);
                djssec = parseInt(enddjs % 60000 / 1000);
                if (djssec && djsmin) {
                    $scope.begindjs = djsmin + '分' + djssec + '秒';
                } else if (!djssec && djsmin) {
                    $scope.begindjs = djsmin + '分';
                } else if (!djsmin) {
                    $scope.begindjs = djssec + '秒';
                }
            }
            if ($scope.djstimes >= $scope.newDate && $scope.djstimes <= cdate) {
                thisdjs = $scope.djstimes - $scope.newDate;
                enddjs = enddjs - thisdjs;
                djsminutes()
                var clear = $interval(function () {
                    if ($scope.djstimes >= cdate) {
                        $scope.djsshowprice = true;
                        $interval.cancel(clear)
                    } else {
                        enddjs = enddjs - 1000;
                        djsminutes();
                    }
                }, 1000)
            }
            $timeout(function () {
                $scope.serviceTime = new Date($scope.serviceTime.getTime() + 1000);
                uranusiscroll.refresh();
            }, 300);
        }
        setproducttime();
        $scope.$on('$destroy', function () {
            $interval.cancel(intervalL)
        })
        var intervalL = $interval(function () {
            setproducttime()
        }, 1000)
    }
    var reqstime, reqetime, reqcha;
    // 获取请求开始的时间
    reqstime = new Date().getTime();
    commonFactory.ajax("/api/UserFlexibleProduct/GetServiceTime", {}, function (result) {
        // 获取请求结束的时间
        reqetime = new Date().getTime();
        // 计算请求所用时间
        reqcha = reqetime - reqstime;
         // 后台返回的时间加上请求所用时间就是当前时间
         $scope.serviceTime = new Date(new Date(parseInt(result.data.serviceTime)).getTime() + reqcha);//
         //时间段
         $scope.thistime = result.data.minute;
         //开始时间
         $scope.gethours = result.data.startTime.substring(0, 2);
         $scope.getMinutes = parseInt(result.data.startTime.substring(3, 5));
         $scope.getSecond = parseInt(result.data.startTime.substring(6, 8));
         timeShow();
    }, function () { }, 'get')

    var heaList = CacheFactory.getStorage("GetFlexibletitle");
    if (heaList) {
        $scope.GetFlexibleUserInfo = heaList;
    }
    commonFactory.ajax("/api/UserFlexibleProduct/GetFlexibleUserInfo", {}, function (result) {//持有金额 昨日收益 累计收益
        if (result.code == 1) {
            if (!commonFactory.comparisonobj(heaList, result.data)) {
                $scope.GetFlexibleUserInfo = result.data;
                CacheFactory.setStorage("GetFlexibletitle", result.data);
            }
        } else if (result.code == 8) {
            commonFactory.gologin();
        }
    }, null, "get");
    $scope.GetCanQuit = 0;
    var ddplacehold = CacheFactory.getStorage("GetCanQuit");
    if (ddplacehold) {
        $scope.GetCanQuit = ddplacehold;
    }
    commonFactory.ajax("/api/UserFlexibleProduct/GetCanExitPrice", {}, function (result) {//取出金额
        if (result.code == 1) {
            if (!commonFactory.comparisonobj(ddplacehold, result.data)) {
                $scope.GetCanQuit = result.data;
                CacheFactory.setStorage("GetCanQuit", result.data);
            }
        } else if (result.code == 8) {
            commonFactory.gologin();
        }
    }, null, "get");
    // $scope.user = null;//用户信息
    // $scope.returns = function (obj) {//向项目明细出入参数
    //     CacheFactory.setStorage("user_daylist", obj);
    //     commonFactory.go('/mine/dayproductdetailed');
    // }
    $scope.submit = {};
    $scope.showpullup = false;//默认隐藏上啦加载
    var cache_getday;
    var loadingArr = [], loadingCount = 2;
    var index = 1, size = 10;
    $scope.isloaded = false;
    $scope.isHide = false;
    var heaPrice = CacheFactory.getStorage("newFlexibleprice");
    if (heaPrice) {
        $scope.newFlexibleprice = heaPrice;
    }
    var getdaylist = function (isload) {
        // $scope.user = CacheFactory.getUser();
        // commonFactory.inputBlur();
        // if (!$scope.user) {//检测登录---弹出
        //     commonFactory.gologin();
        //     return;
        // }
        // 获取已购买天天赚列表
        commonFactory.ajax("/api/FlexibleProduct/GetFlexibleRecordList", { pageIndex: index, pageSize: size }, function (result) {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_getday) {
                loadingArr.push("GetFlexibleRecordList");
            }
            if (result.code == 1) {
                var data = result.data.list;
                $scope.newFlexibleprice = 0;
                //没有数据
                if (index == 1 && data.length == 0) {
                    uranusiscroll.isOverData = true;
                    $scope.isHide = true;
                } else {
                    cache_getday = data;
                    if (index == 1 || !$scope.GetFlexibleRecordList) {
                        $scope.GetFlexibleRecordList = cache_getday;
                    } else {
                        $scope.GetFlexibleRecordList = $scope.GetFlexibleRecordList.concat(cache_getday);
                    }
                    for (var i = $scope.GetFlexibleRecordList.length - 1; i >= 0; i--) {
                        $scope.newFlexibleprice += Number($scope.GetFlexibleRecordList[i].price);
                    }
                    CacheFactory.setStorage("newFlexibleprice", $scope.newFlexibleprice);
                    $timeout(function () {
                        uranusiscroll.refresh();
                    }, appconfig.pulldowntime);
                    if (data.length != size) { //如果没有数据了
                        uranusiscroll.isOverData = true;
                        if (index == 1) { //数据在一页读完

                        } else {
                            $scope.showpullup = true;
                        }
                    } else {
                        index++;
                        $scope.showpullup = true;
                    }
                }
            }
            else if (result.code == 8) {
                commonFactory.gologin();
            }
        }, function () {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_getday) {
                loadingArr.push("GetFlexibleRecordList");
            }
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);
        }, "post");
    }
    getdaylist(true);
    $scope.closelayout = function () {
        commonFactory.messageclose();
    }
    $scope.goDayWithdrawal = function () {
        if ($scope.GetCanQuit && $scope.GetCanQuit > 0) {
            commonFactory.ajax("/api/user/getuserinfo", {}, function (result) {
                if (result.code == 1) {
                    if (result.data.userId <= 0) {
                        commonFactory.gologin();
                        return;
                    }
                    var userinfo = result.data;
                    $scope.userinfo = result.data;
                    if (!userinfo.usrCustId || userinfo.usrCustId == null) {
                        // commonFactory.go("/mine/realname");
                        commonFactory.ajax("/api/bank/gettime", {}, function (result) {
                            if (result.code == 1) {
                                commonFactory.messageclose();
                                var severseTime = new Date(new Date(result.data.replace(/-/g, '/')).getTime()); //服务器时间
                                var nhours = severseTime.getHours();
                                var nminutus = severseTime.getMinutes();
                                if (nhours >= 1 && nhours <= 5) {
                                    var html = '<div id="js_singlePrice">';
                                    html += '       <section class="withtan_box">';
                                    html += '           <p class="clearfix witht_b_tit">';
                                    html += '               <span class="text_center">&nbsp;提示</span>';
                                    html += '               <span class="pull-right with_b_t_icon" ng-click="closelayout()"></span>';
                                    html += '           </p>';
                                    html += '           <div class="withtan_content">';
                                    html += '               <div class="clearfix with_c_div" style="padding-bottom:1.0667rem">';
                                    html += '                   为了保障用户资金安全，平台1:00--5:00为银行对账时段，暂停汇付天下账户开通，请您稍后操作。感谢您的理解与支持。';
                                    html += '               </div>';
                                    html += '               <div class="withtan_content_bth with_c_p_but_color" ng-click="closelayout()">';
                                    html += '                   我知道了';
                                    html += '               </div>';
                                    html += '           </div>';
                                    html += '       </section>';
                                    html += '   </div>';
                                    commonFactory.messageview(html, { width: 1, height: 1 }, $scope);
                                } else {
                                    commonFactory.go('/mine/realname')
                                }
                            }
                        }, function () { }, 'post')
                        return;
                    } else {
                        commonFactory.go('/mine/daywithdrawal');
                    }
                } else if (result.code == 8) {
                    commonFactory.gologin();
                } else {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
                }
            }, function () {
                commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
            }, "post");
        }
    }
    var submit = $scope.submit;
}]);
// 天天赚取出
UranusWei.controller("daywithdrawal", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'uranusPlus', 'appconfig', '$timeout', '$interval', '$stateParams', 'CacheFactory', '$location', function ($scope, $rootScope, uranusiscroll, commonFactory, uranusPlus, appconfig, $timeout, $interval, $stateParams, CacheFactory, $location) {
    $rootScope.Template = {
        title: '天天赚账户取款',
        state: 'daywithdrawal',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,
        opacity: 0
        // backlink: '/mine/daydetailed'
    }
    commonFactory.setBackLink("/mine/daydetailed");
    var dthis = new uranusiscroll();
    uranusiscroll = dthis.init(false, false);
    var pathName = location.pathname;
    var ddplacehold = CacheFactory.getStorage("GetCanQuit");
    if (ddplacehold) {
        $scope.GetCanQuit = ddplacehold;
    }
    CacheFactory.setStorage('time_comebackUrl', '/mine/daywithdrawal', { isExpires: true, expiresTime: CacheFactory.hour * 1 })//设置开户回调地址
    commonFactory.ajax("/api/UserFlexibleProduct/GetCanExitPrice", {}, function (result) {//取出金额
        if (result.code == 1) {
            if (!commonFactory.comparisonobj(ddplacehold, result.data)) {
                $scope.GetCanQuit = result.data;
                CacheFactory.setStorage("GetCanQuit", result.data);
            }
        } else if (result.code == 8) {
            commonFactory.gologin();
        }
    }, null, "get");
    $scope.user = null;//用户信息
    $scope.submit = {
        shopprice: ""
    }
    $scope.daysubmit = {
        Amount: "",
        WithdrawType: "02",
        ReturnUrl: "",
        Remark: "",
        PageType: "2"
    };
    var cache_getday;
    /* 检测输入的金额是否符合购买要求 */
    $scope.GetProfit = function (keypress) {
        checkPrice(true);
    };
    var checkPrice = function (keypress) {
        if ($scope.GetCanQuit) {
            var submit = $scope.submit;
            submit.shopprice = parseFloat(submit.shopprice);
            if (!submit.shopprice || isNaN(parseFloat(submit.shopprice)) || parseFloat(submit.shopprice) == 0) {
                if (!keypress) {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>请输入取出金额</div>" });
                }
                return false;
            }
            if (submit.shopprice > $scope.GetCanQuit) {
                if (!keypress) {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>请输入您可取范围内金额</div>" });
                }
                submit.shopprice = $scope.GetCanQuit
                return false;
            }
            return true;
        } else {
            var submit = $scope.submit;
            submit.shopprice = parseFloat(submit.shopprice);
            if (!keypress) {
                commonFactory.messageshow({ content: "<div class='bg_tan'>您当前无可取金额</div>" });
            }
        }
    };
    var submit = $scope.submit;
    $scope.outPrice = function (type) {
        commonFactory.messageclose();
        commonFactory.inputBlur();
        if (checkPrice()) {
            commonFactory.messageloading({ index: 2000, time: 1000 * 60 * 10 });
            commonFactory.ajax("/api/UserFlexibleProduct/ExitFleibleProduct", { price: submit.shopprice, type: type }, function (result) {
                if (result.code == 1) {
                    var gid = result.data;
                    $scope.requestcount = 1;
                    outPriceResult(gid, 'current', type);//取出
                } else if (result.code == 8) {
                    commonFactory.gologin();
                } else {
                    commonFactory.messageclose();
                    if (result.data) {
                        commonFactory.messageshow({ content: "<div class='bg_tan'>" + result.data + "</div>" });
                    } else {
                        commonFactory.messageshow({ content: "<div class='bg_tan'>操作异常，请联系客服</div>" });
                    }
                }
            }, null, "post");
        }
    }
    function create() {
        var w = plus.webview.create(appconfig.baseurladd + '/setting/bindcard', 'outbankcard', { height: '100%', width: '100%' });
        var ws = plus.webview.currentWebview();
        ws.append(w);
        w.show(); // 显示窗口
        w.onloaded = function () {
            if (w.getTitle() == '汇付天下') {
                $timeout(function () {
                    plus.webview.close('outbankcard');
                }, 2000)
            }
        }
    }
    $scope.closelayout = function () {
        commonFactory.messageclose();
    }

    $scope.outBank = function () {
        if (checkPrice()) {
            commonFactory.ajax("/api/user/getuserinfo", {}, function (result) {
                if (result.code == 1) {
                    if (result.data.userId <= 0) {
                        commonFactory.gologin();
                        return;
                    }
                    var userinfo = result.data;
                    $scope.userinfo = result.data;
                    if (!userinfo.usrCustId || userinfo.usrCustId == null) {
                        // commonFactory.go("/mine/realname");
                        commonFactory.ajax("/api/bank/gettime", {}, function (result) {
                            if (result.code == 1) {
                                commonFactory.messageclose();
                                var severseTime = new Date(new Date(result.data.replace(/-/g, '/')).getTime()); //服务器时间
                                var nhours = severseTime.getHours();
                                var nminutus = severseTime.getMinutes();
                                if (nhours >= 1 && nhours <= 5) {
                                    var html = '<div id="js_singlePrice">';
                                    html += '       <section class="withtan_box">';
                                    html += '           <p class="clearfix witht_b_tit">';
                                    html += '               <span class="text_center">&nbsp;提示</span>';
                                    html += '               <span class="pull-right with_b_t_icon" ng-click="closelayout()"></span>';
                                    html += '           </p>';
                                    html += '           <div class="withtan_content">';
                                    html += '               <div class="clearfix with_c_div" style="padding-bottom:1.0667rem">';
                                    html += '                   为了保障用户资金安全，平台1:00--5:00为银行对账时段，暂停汇付天下账户开通，请您稍后操作。感谢您的理解与支持。';
                                    html += '               </div>';
                                    html += '               <div class="withtan_content_bth with_c_p_but_color" ng-click="closelayout()">';
                                    html += '                   我知道了';
                                    html += '               </div>';
                                    html += '           </div>';
                                    html += '       </section>';
                                    html += '   </div>';
                                    commonFactory.messageview(html, { width: 1, height: 1 }, $scope);
                                } else {
                                    commonFactory.go('/mine/realname')
                                }
                            }
                        }, function () { }, 'post')
                        return;
                    } else if (!userinfo.bankCard || userinfo.bankCard == null) {
                        if (uranusPlus.isApp) {
                            create();//app创建webveiw
                        } else {
                            //跳转汇付天下绑卡
                            commonFactory.ajax("/api/user/UserBindCard", {}, function (result) {
                                if (result.code == 1) {
                                    $scope.html = "";
                                    $scope.html += '<form name="form" id="bindbankform" method="post" action="' + appconfig.hfurl + '">';
                                    for (var i in result.data) {//动态编译form
                                        res = i.substring(0, 1).toUpperCase() + i.substring(1);//处理name值首字母大写
                                        if (result.data[i] == null) {//参数值为null处理为空字符串
                                            result.data[i] = '""';
                                        }
                                        $scope.html += '<input name="' + res + '" id="' + res + '" type="hidden" value=' + result.data[i] + ' />';
                                    }
                                    $scope.html += '</form>';
                                    $timeout(function () {
                                        var bindbankform = document.querySelector('#bindbankform')
                                        bindbankform.submit();
                                    }, 50)
                                } else {
                                    commonFactory.messageshow({ content: "<div class='bg_tan'>后台系统错误</div>" });
                                }
                            }, function () {
                                commonFactory.messageshow({ content: "<div class='bg_tan'>error</div>" });
                            }, "post");

                        }
                    } else {
                        commonFactory.ajax("/api/bank/gettime", {}, function (result) {
                            if (result.code == 1) {
                                var severseTime = new Date(new Date(result.data.replace(/-/g, '/')).getTime()); //服务器时间
                                var month = severseTime.getMonth() + 1;
                                var newdate = severseTime.getDate();
                                var nhours = severseTime.getHours();
                                if (month == 2 && newdate < 5) {
                                    var js_fastpay = document.querySelector("#js_25");
                                    if (js_fastpay) {
                                        commonFactory.messageclose();
                                        var html = js_fastpay.innerHTML;
                                        commonFactory.messageview(html, { height: 1, width: 1, shadeClose: true }, $scope);
                                    }
                                } else if (month == 2 && newdate >= 14 && newdate <= 21) {
                                    var js_fastpay = document.querySelector("#js_gq");
                                    if (js_fastpay) {
                                        commonFactory.messageclose();
                                        var html = js_fastpay.innerHTML;
                                        commonFactory.messageview(html, { height: 1, width: 1, shadeClose: true }, $scope);
                                    }
                                } else {
                                    $scope.outPrice(1)
                                }
                            }
                        }, function () { }, 'post')
                    }
                } else if (result.code == 8) {
                    commonFactory.gologin();
                } else {
                    commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
                }
            }, function () {
                commonFactory.messageshow({ content: "<div class='bg_tan'>获取用户信息失败</div>" });
            }, "post");
        }
    }
    // 关闭弹框
    $scope.closelayout = function () {
        if ($scope.djsresult) {
            $interval.cancel($scope.djsresult);
        }
        commonFactory.messageclose();
    }
    var outPriceResult = function (gid, name, type) {
        commonFactory.ajax("/api/UserFlexibleProduct/GetIsExitSucess", { orderId: gid }, function (result) {
            if (result.data) {
                commonFactory.messageclose();
                if (!type) {//0为取出到余额
                    if (name == "current") {
                        commonFactory.go("/other/transfercomplete?state=true&desc=成功&type=" + name);
                    }
                } else {//1为取出到银行卡
                    $scope.daysubmit.Amount = Number(submit.shopprice).toFixed(2);
                    $scope.daysubmit.Remark = gid;
                    $scope.daysubmit.ReturnUrl = appconfig.baseurladd + '/other/waitting?type=current'
                    commonFactory.ajax("/api/Bank/Withdraw", $scope.daysubmit, function (result) {
                        if (result.code == 1) {
                            CacheFactory.setStorage("time_queryresult", result.data.merPriv);
                            var formObject = document.querySelector('#daywithdrawalform')
                            formObject.action = appconfig.hfurl;
                            $scope.ajaxdata = result.data;
                            $timeout(function () {
                                formObject.submit();
                            }, 50)
                        } else {
                            if (result.data) {
                                commonFactory.messageshow({ content: "<div class='bg_tan'>" + result.data + "</div>" });
                            } else {
                                commonFactory.messageshow({ content: "<div class='bg_tan'>提现请求错误</div>" });
                            }
                        }
                    }, function () {

                    }, "post");
                }
            } else if (result.data == null) {
                if ($scope.requestcount < 500) {
                    $scope.requestcount++;
                    $timeout(function () {
                        outPriceResult(gid, name, type);
                    }, 1000);
                } else {
                    commonFactory.go("/other/transfercomplete?state=false&desc=失败&type=" + name);
                }
            } else if (result.code == 8) {
                commonFactory.gologin();
            } else {
                commonFactory.messageclose();
                commonFactory.go("/other/transfercomplete?state=false&desc=失败&type=" + name);
            }
        }, function () {
        }, "get");
    }
}]);
// 活期合同
UranusWei.controller("currentcp", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'uranusPlus', 'appconfig', '$timeout', '$interval', '$stateParams', 'CacheFactory', '$location', function ($scope, $rootScope, uranusiscroll, commonFactory, uranusPlus, appconfig, $timeout, $interval, $stateParams, CacheFactory, $location) {
    $rootScope.Template = {
        title: '',
        state: '',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,//下拉显示顶部导航的功能 
    }
    // commonFactory.setBackLink("/mine/dayproductdetailed");//设置返回连接
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(true);
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    var GetDetailListData = CacheFactory.getStorage('GetDetailListData');
    if (window.location.pathname == "/contract/contract-xy") {
        $scope.Template.title = "有利金服免责声明"
    } else if (window.location.pathname == "/contract/contract-serves" || window.location.pathname == "/contract/contract-hqserves") {
        $scope.Template.title = "定向委托投资协议"
    } else if (window.location.pathname == "/contract/contract-msg") {
        $scope.Template.title = "风险提示函"
    } else if (window.location.pathname == "/contract/anxin") {
        $scope.Template.title = "安心签平台服务协议"
    } else if (window.location.pathname == "/contract/cfca") {
        $scope.Template.title = "CFCA数字证书服务协议"
    }
}]);
//天天赚收益明细
UranusWei.controller("daygetdetailed", ['$scope', '$rootScope', 'uranusiscroll', 'commonFactory', 'uranusPlus', 'appconfig', '$timeout', '$interval', '$stateParams', 'CacheFactory', '$location', function ($scope, $rootScope, uranusiscroll, commonFactory, uranusPlus, appconfig, $timeout, $interval, $stateParams, CacheFactory, $location) {
    $rootScope.Template = {
        title: '天天赚收益明细',
        state: 'daygetdetailed',
        showbackicon: true,
        showheader: true,
        slideopeacity: true,
        opacity: 0
    }
    commonFactory.setBackLink("/mine/daydetailed");
    var dthis = new uranusiscroll();
    var text = commonFactory.GetRandomPullAd();
    dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
    uranusiscroll = dthis.init(false, true);
    var pathName = location.pathname;
    uranusiscroll.scrollMove = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }
    uranusiscroll.scrollEnd = function () {
        commonFactory.slideopeacity(uranusiscroll, pathName);
    }
    uranusiscroll.pullDownAction = function () {
        text = commonFactory.GetRandomPullAd();
        dthis.showtext({ downtext: text, opentext: text, loadingtext: text });
        $timeout(function () {
            uranusiscroll.refresh();
        }, appconfig.pulldowntime);
    }
    uranusiscroll.pullUpAction = function () {
        getproductlist(true);
    }
    $scope.showproductpullup = false;
    var cache_getdetailedx;
    var loadingArr = [], loadingCount = 2;
    var index = 1, size = 20;
    $scope.isloaded = false;
    $scope.isHide = false;
    var getproductlist = function (isload) {
        $scope.user = CacheFactory.getUser();
        commonFactory.inputBlur();
        if (!$scope.user) {//检测登录---弹出
            commonFactory.gologin();
            return;
        }
        commonFactory.ajax("/api/FlexibleProduct/GetFlexibleInterestDetail", { pageIndex: index, pageSize: size }, function (result) {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_getdetailedx) {
                loadingArr.push("GetFlexibleInterestDetail");
            }
            if (result.code == 1) {
                var data = result.data.list;
                //没有数据
                if (index == 1 && data.length == 0) {
                    uranusiscroll.isOverData = true;
                    $scope.isHide = true;
                } else {
                    cache_getdetailedx = data;
                    if (index == 1 || !$scope.GetFlexibleInterestDetail) {
                        $scope.GetFlexibleInterestDetail = cache_getdetailedx;
                    } else {
                        $scope.GetFlexibleInterestDetail = $scope.GetFlexibleInterestDetail.concat(cache_getdetailedx);
                    }
                    $timeout(function () {
                        uranusiscroll.refresh();
                    }, appconfig.pulldowntime);
                    if (data.length != size) { //如果没有数据了
                        uranusiscroll.isOverData = true;
                        if (index == 1) { //数据在一页读完

                        } else {
                            $scope.showproductpullup = true;
                        }
                    } else {
                        index++;
                        $scope.showproductpullup = true;
                    }
                }

            }
        }, function () {
            $scope.isloaded = true;
            if (isload) {
                commonFactory.messageclose();
            }
            if (!cache_getdetailedx) {
                loadingArr.push("GetFlexibleInterestDetail");
            }
            $timeout(function () {
                uranusiscroll.refresh();
            }, appconfig.pulldowntime);
        }, "post");
    }
    getproductlist(true);
}]);
//活期提现
UranusWei.controller("fmoutbank", ['$scope', '$rootScope', 'uranusPlus', 'commonFactory', 'appconfig', '$timeout', '$stateParams', 'uranusiscroll', 'CacheFactory', '$interval', function ($scope, $rootScope, uranusPlus, commonFactory, appconfig, $timeout, $stateParams, uranusiscroll, CacheFactory, $interval) {
    var clear = $interval(function () {
        var outbankcard = CacheFactory.getStorage('outbankdata')
        commonFactory.messageclose();
        if (outbankcard) {
            $interval.cancel(clear)
            $scope.formdata = outbankcard
            var formObject = document.querySelector('form')
            formObject.action = $scope.formdata.url;
            $timeout(function () {
                formObject.submit();
            }, 100)
            CacheFactory.setStorage('outbankcard', '')
        }
    }, 10)
}]);
